'use strict';

const router = require('koa-router')();
const bodyParser = require('koa-bodyparser');
const { findControllers, registryRouter } = require('../utils/tools');


function processRouter(app) {
    //1、找到所有的路由文件
    let controllers = findControllers();
    // console.log(controllers);
    //2、遍历注册所有的路由
    registryRouter(controllers,router);

    app.use(bodyParser());
    app.use(router.routes());
}

module.exports = processRouter